import shutil, random, string
from pathlib import Path

p = Path('/Users/bob/Downloads')
dirname = p / 'tmp'

# 创建目录及文件
#src_dir = dirname / 'a' / 'b' 
#src_dir.mkdir(parents=True, exist_ok=True)

#for i in range(10):
#    rand_dir = random.choice(list(dirname.rglob('[a-z]')))
#    rand_file = ''.join(random.choices(string.ascii_lowercase, k=4))
#    (rand_dir / rand_file).with_suffix('.htm').touch()

files = dirname.rglob('*.htm')

for file in files:
    new_file = file.with_suffix('.html')
    shutil.move(file, new_file)




